for (1..52/4){      # arrange cards to person
  for $person qw(Rose Mary John Peter){
      $group = (keys %cards)[int rand(keys %cards)];
      $number = shift @{ $cards{$group} };
      delete $cards{$group} if @{ $cards{$group} } == 0;
      push @{$game{$person}{$group}},$numbers[$number];
}}

foreach $person (keys %game){    #print the arrangement
  print "$person: \n";
  foreach $group ( keys %{ $game{$person} } ){
    print "\t($group ",
    join(" ",@{$game{$person}{$group}}),")\n";
}}
